/*--------------------------------------------------------------
-- Use the next lines if you want to drop/create database

use [master]
go

drop database [FlowTasks]
go

create database [FlowTasks]
go

use [FlowTasks]
go
*/

IF (EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'Holiday'))
BEGIN
	RAISERROR ('The database is not empty, please drop the database before running this script', 15, 1)
END


/*--------------------------------------------------------------

CREATE DATABASE

--------------------------------------------------------------*/

CREATE TABLE [dbo].[Holiday] (
    [HolidayId] [int] NOT NULL IDENTITY,
    [User] [nvarchar](16),
    [Year] [int] NOT NULL,
    [Status] [nvarchar](1) NOT NULL,
    [HolidayTypeId] [int] NOT NULL,
    [Dates] [nvarchar](200) NOT NULL,
    CONSTRAINT [PK_dbo.Holiday] PRIMARY KEY ([HolidayId])
)
CREATE TABLE [dbo].[HolidayType] (
    [HolidayTypeId] [int] NOT NULL IDENTITY,
    [Type] [nvarchar](20) NOT NULL,
    [Description] [nvarchar](200),
    CONSTRAINT [PK_dbo.HolidayType] PRIMARY KEY ([HolidayTypeId])
)
CREATE TABLE [dbo].[Property] (
    [PropertyId] [int] NOT NULL IDENTITY,
    [Name] [nvarchar](200) NOT NULL,
    [Value] [nvarchar](200),
    [Type] [nvarchar](20),
    CONSTRAINT [PK_dbo.Property] PRIMARY KEY ([PropertyId])
)
CREATE TABLE [dbo].[SketchConfiguration] (
    [SketchConfigurationId] [int] NOT NULL IDENTITY,
    [Name] [nvarchar](200),
    [XamlxOid] [uniqueidentifier] NOT NULL,
    [LastSavedOn] [datetime] NOT NULL,
    [ChangedBy] [nvarchar](16),
    [SketchStatusId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.SketchConfiguration] PRIMARY KEY ([SketchConfigurationId])
)
CREATE TABLE [dbo].[SketchStatus] (
    [SketchStatusId] [int] NOT NULL IDENTITY,
    [Status] [nvarchar](20) NOT NULL,
    [Description] [nvarchar](200),
    CONSTRAINT [PK_dbo.SketchStatus] PRIMARY KEY ([SketchStatusId])
)
CREATE TABLE [dbo].[TaskConfiguration] (
    [TaskConfigurationId] [int] NOT NULL IDENTITY,
    [TaskCode] [nvarchar](20),
    [Title] [nvarchar](200),
    [Description] [nvarchar](500),
    [CanBeHandedOver] [bit] NOT NULL,
    [HandOverUsers] [nvarchar](200),
    [AssignedToUsers] [nvarchar](200),
    [UiCode] [nvarchar](20),
    [DefaultResult] [nvarchar](20),
    [WorkflowCodeId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.TaskConfiguration] PRIMARY KEY ([TaskConfigurationId])
)
CREATE TABLE [dbo].[WorkflowCode] (
    [WorkflowCodeId] [int] NOT NULL IDENTITY,
    [Code] [nvarchar](50) NOT NULL,
    [Description] [nvarchar](200),
    CONSTRAINT [PK_dbo.WorkflowCode] PRIMARY KEY ([WorkflowCodeId])
)
CREATE TABLE [dbo].[TaskDefinition] (
    [TaskDefinitionId] [int] NOT NULL IDENTITY,
    [TaskOid] [uniqueidentifier] NOT NULL,
    [TaskCorrelationId] [int] NOT NULL,
    [TaskCode] [nvarchar](50) NOT NULL,
    [UiCode] [nvarchar](200) NOT NULL,
    [Title] [nvarchar](200),
    [Description] [nvarchar](500),
    [DefaultResult] [nvarchar](20),
    [ExpiryDate] [datetime],
    [AcceptedOn] [datetime],
    [AcceptedBy] [nvarchar](16),
    [CompletedOn] [datetime],
    [AcceptUser] [nvarchar](16),
    [CanBeHandedOver] [bit] NOT NULL,
    [HandedOverStatus] [nvarchar](20),
    [WorkflowDefinitionId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.TaskDefinition] PRIMARY KEY ([TaskDefinitionId])
)
CREATE TABLE [dbo].[WorkflowDefinition] (
    [WorkflowDefinitionId] [int] NOT NULL IDENTITY,
    [WorkflowOid] [uniqueidentifier] NOT NULL,
    [CompletedOn] [datetime],
    [StartedOn] [datetime] NOT NULL,
    [Domain] [nvarchar](50),
    [WorkflowParentDefinitionId] [int],
    [WorkflowCodeId] [int] NOT NULL,
    [WorkflowStatusId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.WorkflowDefinition] PRIMARY KEY ([WorkflowDefinitionId])
)
CREATE TABLE [dbo].[WorkflowStatus] (
    [WorkflowStatusId] [int] NOT NULL IDENTITY,
    [Status] [nvarchar](20) NOT NULL,
    [Description] [nvarchar](200),
    CONSTRAINT [PK_dbo.WorkflowStatus] PRIMARY KEY ([WorkflowStatusId])
)
CREATE TABLE [dbo].[TaskInParameter] (
    [TaskInParameterId] [int] NOT NULL IDENTITY,
    [PropertyId] [int] NOT NULL,
    [TaskDefinitionId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.TaskInParameter] PRIMARY KEY ([TaskInParameterId])
)
CREATE TABLE [dbo].[TaskOutParameter] (
    [TaskOutParameterId] [int] NOT NULL IDENTITY,
    [PropertyId] [int] NOT NULL,
    [TaskDefinitionId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.TaskOutParameter] PRIMARY KEY ([TaskOutParameterId])
)
CREATE TABLE [dbo].[TaskProperty] (
    [TaskPropertyId] [int] NOT NULL IDENTITY,
    [TaskCode] [nvarchar](20) NOT NULL,
    [PropertyId] [int] NOT NULL,
    [WorkflowCodeId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.TaskProperty] PRIMARY KEY ([TaskPropertyId])
)
CREATE TABLE [dbo].[TaskUserHandOver] (
    [TaskUserHandOverId] [int] NOT NULL IDENTITY,
    [User] [nvarchar](16) NOT NULL,
    [InUse] [bit] NOT NULL,
    [TaskDefinitionId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.TaskUserHandOver] PRIMARY KEY ([TaskUserHandOverId])
)
CREATE TABLE [dbo].[TaskUser] (
    [TaskUserId] [int] NOT NULL IDENTITY,
    [User] [nvarchar](16) NOT NULL,
    [InUse] [bit] NOT NULL,
    [TaskDefinitionId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.TaskUser] PRIMARY KEY ([TaskUserId])
)
CREATE TABLE [dbo].[TopicAttachment] (
    [TopicAttachmentId] [int] NOT NULL IDENTITY,
    [FileName] [nvarchar](200),
    [OidDocument] [uniqueidentifier] NOT NULL,
    [TopicMessageId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.TopicAttachment] PRIMARY KEY ([TopicAttachmentId])
)
CREATE TABLE [dbo].[TopicMessage] (
    [TopicMessageId] [int] NOT NULL IDENTITY,
    [Message] [nvarchar](500),
    [From] [nvarchar](20),
    [To] [nvarchar](200),
    [When] [datetime] NOT NULL,
    [IsTopic] [bit] NOT NULL,
    [TopicId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.TopicMessage] PRIMARY KEY ([TopicMessageId])
)
CREATE TABLE [dbo].[Topic] (
    [TopicId] [int] NOT NULL IDENTITY,
    [Title] [nvarchar](200),
    [LastChanged] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.Topic] PRIMARY KEY ([TopicId])
)
CREATE TABLE [dbo].[TopicStatus] (
    [TopicStatusId] [int] NOT NULL IDENTITY,
    [Status] [nvarchar](20) NOT NULL,
    [Description] [nvarchar](200),
    CONSTRAINT [PK_dbo.TopicStatus] PRIMARY KEY ([TopicStatusId])
)
CREATE TABLE [dbo].[TopicUser] (
    [TopicUserId] [int] NOT NULL IDENTITY,
    [User] [nvarchar](16) NOT NULL,
    [TopicMessageId] [int] NOT NULL,
    [TopicStatusId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.TopicUser] PRIMARY KEY ([TopicUserId])
)
CREATE TABLE [dbo].[TraceEvent] (
    [TraceEventId] [int] NOT NULL IDENTITY,
    [Type] [nvarchar](20) NOT NULL,
    [Description] [nvarchar](200),
    CONSTRAINT [PK_dbo.TraceEvent] PRIMARY KEY ([TraceEventId])
)
CREATE TABLE [dbo].[WorkflowConfiguration] (
    [WorkflowConfigurationId] [int] NOT NULL IDENTITY,
    [ServiceDefinition] [nvarchar](max),
    [ServiceUrl] [nvarchar](256),
    [BindingConfiguration] [nvarchar](50),
    [ServiceEndpoint] [nvarchar](50),
    [EffectiveDate] [datetime] NOT NULL,
    [ExpiryDate] [datetime],
    [WorkflowCodeId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.WorkflowConfiguration] PRIMARY KEY ([WorkflowConfigurationId])
)
CREATE TABLE [dbo].[WorkflowInParameter] (
    [WorkflowInParameterId] [int] NOT NULL IDENTITY,
    [PropertyId] [int] NOT NULL,
    [WorkflowDefinitionId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.WorkflowInParameter] PRIMARY KEY ([WorkflowInParameterId])
)
CREATE TABLE [dbo].[WorkflowOutParameter] (
    [WorkflowOutParameterId] [int] NOT NULL IDENTITY,
    [PropertyId] [int] NOT NULL,
    [WorkflowDefinitionId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.WorkflowOutParameter] PRIMARY KEY ([WorkflowOutParameterId])
)
CREATE TABLE [dbo].[WorkflowProperty] (
    [WorkflowPropertyId] [int] NOT NULL IDENTITY,
    [Domain] [nvarchar](50),
    [WorkflowCodeId] [int] NOT NULL,
    [PropertyId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.WorkflowProperty] PRIMARY KEY ([WorkflowPropertyId])
)
CREATE TABLE [dbo].[WorkflowTrace] (
    [WorkflowTraceId] [int] NOT NULL IDENTITY,
    [When] [datetime] NOT NULL,
    [User] [nvarchar](16),
    [Action] [nvarchar](20),
    [Result] [nvarchar](20),
    [Code] [nvarchar](20),
    [Message] [nvarchar](500),
    [WorkflowDefinitionId] [int] NOT NULL,
    [TraceEventId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.WorkflowTrace] PRIMARY KEY ([WorkflowTraceId])
)
CREATE INDEX [IX_HolidayTypeId] ON [dbo].[Holiday]([HolidayTypeId])
CREATE INDEX [IX_SketchStatusId] ON [dbo].[SketchConfiguration]([SketchStatusId])
CREATE INDEX [IX_WorkflowCodeId] ON [dbo].[TaskConfiguration]([WorkflowCodeId])
CREATE INDEX [IX_WorkflowDefinitionId] ON [dbo].[TaskDefinition]([WorkflowDefinitionId])
CREATE INDEX [IX_WorkflowParentDefinitionId] ON [dbo].[WorkflowDefinition]([WorkflowParentDefinitionId])
CREATE INDEX [IX_WorkflowCodeId] ON [dbo].[WorkflowDefinition]([WorkflowCodeId])
CREATE INDEX [IX_WorkflowStatusId] ON [dbo].[WorkflowDefinition]([WorkflowStatusId])
CREATE INDEX [IX_PropertyId] ON [dbo].[TaskInParameter]([PropertyId])
CREATE INDEX [IX_TaskDefinitionId] ON [dbo].[TaskInParameter]([TaskDefinitionId])
CREATE INDEX [IX_PropertyId] ON [dbo].[TaskOutParameter]([PropertyId])
CREATE INDEX [IX_TaskDefinitionId] ON [dbo].[TaskOutParameter]([TaskDefinitionId])
CREATE INDEX [IX_PropertyId] ON [dbo].[TaskProperty]([PropertyId])
CREATE INDEX [IX_WorkflowCodeId] ON [dbo].[TaskProperty]([WorkflowCodeId])
CREATE INDEX [IX_TaskDefinitionId] ON [dbo].[TaskUserHandOver]([TaskDefinitionId])
CREATE INDEX [IX_TaskDefinitionId] ON [dbo].[TaskUser]([TaskDefinitionId])
CREATE INDEX [IX_TopicMessageId] ON [dbo].[TopicAttachment]([TopicMessageId])
CREATE INDEX [IX_TopicId] ON [dbo].[TopicMessage]([TopicId])
CREATE INDEX [IX_TopicMessageId] ON [dbo].[TopicUser]([TopicMessageId])
CREATE INDEX [IX_TopicStatusId] ON [dbo].[TopicUser]([TopicStatusId])
CREATE INDEX [IX_WorkflowCodeId] ON [dbo].[WorkflowConfiguration]([WorkflowCodeId])
CREATE INDEX [IX_PropertyId] ON [dbo].[WorkflowInParameter]([PropertyId])
CREATE INDEX [IX_WorkflowDefinitionId] ON [dbo].[WorkflowInParameter]([WorkflowDefinitionId])
CREATE INDEX [IX_PropertyId] ON [dbo].[WorkflowOutParameter]([PropertyId])
CREATE INDEX [IX_WorkflowDefinitionId] ON [dbo].[WorkflowOutParameter]([WorkflowDefinitionId])
CREATE INDEX [IX_WorkflowCodeId] ON [dbo].[WorkflowProperty]([WorkflowCodeId])
CREATE INDEX [IX_PropertyId] ON [dbo].[WorkflowProperty]([PropertyId])
CREATE INDEX [IX_WorkflowDefinitionId] ON [dbo].[WorkflowTrace]([WorkflowDefinitionId])
CREATE INDEX [IX_TraceEventId] ON [dbo].[WorkflowTrace]([TraceEventId])
ALTER TABLE [dbo].[Holiday] ADD CONSTRAINT [FK_dbo.Holiday_dbo.HolidayType_HolidayTypeId] FOREIGN KEY ([HolidayTypeId]) REFERENCES [dbo].[HolidayType] ([HolidayTypeId]) ON DELETE CASCADE
ALTER TABLE [dbo].[SketchConfiguration] ADD CONSTRAINT [FK_dbo.SketchConfiguration_dbo.SketchStatus_SketchStatusId] FOREIGN KEY ([SketchStatusId]) REFERENCES [dbo].[SketchStatus] ([SketchStatusId]) ON DELETE CASCADE
ALTER TABLE [dbo].[TaskConfiguration] ADD CONSTRAINT [FK_dbo.TaskConfiguration_dbo.WorkflowCode_WorkflowCodeId] FOREIGN KEY ([WorkflowCodeId]) REFERENCES [dbo].[WorkflowCode] ([WorkflowCodeId]) ON DELETE CASCADE
ALTER TABLE [dbo].[TaskDefinition] ADD CONSTRAINT [FK_dbo.TaskDefinition_dbo.WorkflowDefinition_WorkflowDefinitionId] FOREIGN KEY ([WorkflowDefinitionId]) REFERENCES [dbo].[WorkflowDefinition] ([WorkflowDefinitionId]) ON DELETE CASCADE
ALTER TABLE [dbo].[WorkflowDefinition] ADD CONSTRAINT [FK_dbo.WorkflowDefinition_dbo.WorkflowCode_WorkflowCodeId] FOREIGN KEY ([WorkflowCodeId]) REFERENCES [dbo].[WorkflowCode] ([WorkflowCodeId]) ON DELETE CASCADE
ALTER TABLE [dbo].[WorkflowDefinition] ADD CONSTRAINT [FK_dbo.WorkflowDefinition_dbo.WorkflowDefinition_WorkflowParentDefinitionId] FOREIGN KEY ([WorkflowParentDefinitionId]) REFERENCES [dbo].[WorkflowDefinition] ([WorkflowDefinitionId])
ALTER TABLE [dbo].[WorkflowDefinition] ADD CONSTRAINT [FK_dbo.WorkflowDefinition_dbo.WorkflowStatus_WorkflowStatusId] FOREIGN KEY ([WorkflowStatusId]) REFERENCES [dbo].[WorkflowStatus] ([WorkflowStatusId]) ON DELETE CASCADE
ALTER TABLE [dbo].[TaskInParameter] ADD CONSTRAINT [FK_dbo.TaskInParameter_dbo.Property_PropertyId] FOREIGN KEY ([PropertyId]) REFERENCES [dbo].[Property] ([PropertyId]) ON DELETE CASCADE
ALTER TABLE [dbo].[TaskInParameter] ADD CONSTRAINT [FK_dbo.TaskInParameter_dbo.TaskDefinition_TaskDefinitionId] FOREIGN KEY ([TaskDefinitionId]) REFERENCES [dbo].[TaskDefinition] ([TaskDefinitionId]) ON DELETE CASCADE
ALTER TABLE [dbo].[TaskOutParameter] ADD CONSTRAINT [FK_dbo.TaskOutParameter_dbo.Property_PropertyId] FOREIGN KEY ([PropertyId]) REFERENCES [dbo].[Property] ([PropertyId]) ON DELETE CASCADE
ALTER TABLE [dbo].[TaskOutParameter] ADD CONSTRAINT [FK_dbo.TaskOutParameter_dbo.TaskDefinition_TaskDefinitionId] FOREIGN KEY ([TaskDefinitionId]) REFERENCES [dbo].[TaskDefinition] ([TaskDefinitionId]) ON DELETE CASCADE
ALTER TABLE [dbo].[TaskProperty] ADD CONSTRAINT [FK_dbo.TaskProperty_dbo.Property_PropertyId] FOREIGN KEY ([PropertyId]) REFERENCES [dbo].[Property] ([PropertyId]) ON DELETE CASCADE
ALTER TABLE [dbo].[TaskProperty] ADD CONSTRAINT [FK_dbo.TaskProperty_dbo.WorkflowCode_WorkflowCodeId] FOREIGN KEY ([WorkflowCodeId]) REFERENCES [dbo].[WorkflowCode] ([WorkflowCodeId]) ON DELETE CASCADE
ALTER TABLE [dbo].[TaskUserHandOver] ADD CONSTRAINT [FK_dbo.TaskUserHandOver_dbo.TaskDefinition_TaskDefinitionId] FOREIGN KEY ([TaskDefinitionId]) REFERENCES [dbo].[TaskDefinition] ([TaskDefinitionId]) ON DELETE CASCADE
ALTER TABLE [dbo].[TaskUser] ADD CONSTRAINT [FK_dbo.TaskUser_dbo.TaskDefinition_TaskDefinitionId] FOREIGN KEY ([TaskDefinitionId]) REFERENCES [dbo].[TaskDefinition] ([TaskDefinitionId]) ON DELETE CASCADE
ALTER TABLE [dbo].[TopicAttachment] ADD CONSTRAINT [FK_dbo.TopicAttachment_dbo.TopicMessage_TopicMessageId] FOREIGN KEY ([TopicMessageId]) REFERENCES [dbo].[TopicMessage] ([TopicMessageId]) ON DELETE CASCADE
ALTER TABLE [dbo].[TopicMessage] ADD CONSTRAINT [FK_dbo.TopicMessage_dbo.Topic_TopicId] FOREIGN KEY ([TopicId]) REFERENCES [dbo].[Topic] ([TopicId]) ON DELETE CASCADE
ALTER TABLE [dbo].[TopicUser] ADD CONSTRAINT [FK_dbo.TopicUser_dbo.TopicMessage_TopicMessageId] FOREIGN KEY ([TopicMessageId]) REFERENCES [dbo].[TopicMessage] ([TopicMessageId]) ON DELETE CASCADE
ALTER TABLE [dbo].[TopicUser] ADD CONSTRAINT [FK_dbo.TopicUser_dbo.TopicStatus_TopicStatusId] FOREIGN KEY ([TopicStatusId]) REFERENCES [dbo].[TopicStatus] ([TopicStatusId]) ON DELETE CASCADE
ALTER TABLE [dbo].[WorkflowConfiguration] ADD CONSTRAINT [FK_dbo.WorkflowConfiguration_dbo.WorkflowCode_WorkflowCodeId] FOREIGN KEY ([WorkflowCodeId]) REFERENCES [dbo].[WorkflowCode] ([WorkflowCodeId]) ON DELETE CASCADE
ALTER TABLE [dbo].[WorkflowInParameter] ADD CONSTRAINT [FK_dbo.WorkflowInParameter_dbo.Property_PropertyId] FOREIGN KEY ([PropertyId]) REFERENCES [dbo].[Property] ([PropertyId]) ON DELETE CASCADE
ALTER TABLE [dbo].[WorkflowInParameter] ADD CONSTRAINT [FK_dbo.WorkflowInParameter_dbo.WorkflowDefinition_WorkflowDefinitionId] FOREIGN KEY ([WorkflowDefinitionId]) REFERENCES [dbo].[WorkflowDefinition] ([WorkflowDefinitionId]) ON DELETE CASCADE
ALTER TABLE [dbo].[WorkflowOutParameter] ADD CONSTRAINT [FK_dbo.WorkflowOutParameter_dbo.Property_PropertyId] FOREIGN KEY ([PropertyId]) REFERENCES [dbo].[Property] ([PropertyId]) ON DELETE CASCADE
ALTER TABLE [dbo].[WorkflowOutParameter] ADD CONSTRAINT [FK_dbo.WorkflowOutParameter_dbo.WorkflowDefinition_WorkflowDefinitionId] FOREIGN KEY ([WorkflowDefinitionId]) REFERENCES [dbo].[WorkflowDefinition] ([WorkflowDefinitionId]) ON DELETE CASCADE
ALTER TABLE [dbo].[WorkflowProperty] ADD CONSTRAINT [FK_dbo.WorkflowProperty_dbo.Property_PropertyId] FOREIGN KEY ([PropertyId]) REFERENCES [dbo].[Property] ([PropertyId]) ON DELETE CASCADE
ALTER TABLE [dbo].[WorkflowProperty] ADD CONSTRAINT [FK_dbo.WorkflowProperty_dbo.WorkflowCode_WorkflowCodeId] FOREIGN KEY ([WorkflowCodeId]) REFERENCES [dbo].[WorkflowCode] ([WorkflowCodeId]) ON DELETE CASCADE
ALTER TABLE [dbo].[WorkflowTrace] ADD CONSTRAINT [FK_dbo.WorkflowTrace_dbo.TraceEvent_TraceEventId] FOREIGN KEY ([TraceEventId]) REFERENCES [dbo].[TraceEvent] ([TraceEventId]) ON DELETE CASCADE
ALTER TABLE [dbo].[WorkflowTrace] ADD CONSTRAINT [FK_dbo.WorkflowTrace_dbo.WorkflowDefinition_WorkflowDefinitionId] FOREIGN KEY ([WorkflowDefinitionId]) REFERENCES [dbo].[WorkflowDefinition] ([WorkflowDefinitionId]) ON DELETE CASCADE
CREATE TABLE [dbo].[__MigrationHistory] (
    [MigrationId] [nvarchar](150) NOT NULL,
    [ContextKey] [nvarchar](300) NOT NULL,
    [Model] [varbinary](max) NOT NULL,
    [ProductVersion] [nvarchar](32) NOT NULL,
    CONSTRAINT [PK_dbo.__MigrationHistory] PRIMARY KEY ([MigrationId], [ContextKey])
)
INSERT [dbo].[__MigrationHistory]([MigrationId], [ContextKey], [Model], [ProductVersion])
VALUES (N'201408080511574_AutomaticMigration', N'Flow.Tasks.Data.Migrations.Configuration',  0x1F8B0800000000000400ED5D6D8FDCB891FE7EC0FD87467FBA0B36D3F62E36488C9904F68C9D1859AF171E7B937C1AC8DD9C1961D5EA8EA49ECCE070BFEC3EDC4FBABF70524BADE64B55B128516FBD83058C1D912C92C587C522597CFAFFFEE77FCFFFF4B88E660F2249C34D7C317F79F6623E13F172B30AE3BB8BF92EBBFDEDEFE77FFAE3BFFFDBF9DBD5FA71F6F321DF7745BEBC649C5ECCEFB36CFB6AB14897F7621DA467EB70996CD2CD6D76B6DCAC17C16AB3F8F6C58B3F2C5EBE5C885CC43C97359B9D7FDAC559B816FB3FF23F2F37F1526CB35D107DD8AC449456DFF394EBBDD4D98FC15AA4DB60292EE6EFA2CDBFCE3E07E92FE9D9559005F3D9EB280CF2665C8BE8763E0BE278930559DEC8575F52719D259BF8EE7A9B7F08A2CF4F5B91E7BB0DA254548D7F75CCCEEDC78B6F8B7E2C8E050FA296BB34DBAC1D05BEFCAE52CC422FDE48BDF35A71B9EADEE62ACE9E8A5EEFD57731FFCB260A57C1D37CA6D7F5EA324A8A7C8672CF2E378938ABCA7D33D352BFA9F190C3A6F8EF9BD9E52ECA7689B888C52E4B82E89BD94FBBAF51B8FCAB78FABCF945C417F12E8AE446E6CDCCD3940FF9A79F92CD5624D9D32771AB36FDFD6A3E5BA8C5177AF9BAB459B4ECE3FB38FBEEDBF9ECC7BC29C1D748D48890F4719DE5FDFEB38845126462F553906522C907F4FD4AEC756A3442AB32475E72A82D87603E95E6B30FC1E30F22BECBEEF349F6BBF9EC5DF82856870F5503BEC4613EF1F23259B213B63AFE2182C4D6235AC275DED95D4AB593D54CC75AABE1282AB50F092D2AC7A0A0DA9F4F0C2F3DF8317808EFF6C0C0FB329F7D12D13E4F7A1F6E4B6B749838374ABE77C966FD69131D8BCBC937D79B5DB2CC737DDEE0793E07C99DC8D4669E2F8ED39D6304CAB6343304458E11188303841A1A041E02FD198552E30458BB986D57225D26E1B65C505A4F9446803BB4C8196D87824342EDF0A509CEE4B27D81ACF8B7078BA8D5FA7310ED7C54DBC7046A84E1EB5F44B6BCCFBDD4DBF06E9754FE99239C011943221B684E13902362268677BA92BF07EBE8F1635877EBCFBBE2FF1DE7C80F419A5D070F62F5B1B6C485FFF2395CBBCFB7CBFB20BE13AB374F5D3B99E5E8968EA2B3B786BA4DB254D06F024075A3163A3A51B6BC8647652DD0CABD529BD9C844948587B70DC7616F6614B8B0F1670DAC3B9A9375B20A98B45B9E0C094302D0684C131482427AF3F6F795AF3C3B2C403D611675BF02F210FEBD97BA2E83F88DF84B10AFF2A5F2E1788EF266935BEF20763F6FC82515728A33191F8705746DAFD334BC8BC5EAF3A69FFABE847D80EC4ADC06F94CFF24D2FCDFAE2BFBDB26F9E536B73C45C7FCF91CB254D0E730ACC58D5AE4E871D0390D7FC392BD95B7A136D1D1E2CB858734F6FA80BBDA7937C0F833F19699F7FD29FB1AB94508E3B0B1A3712C3EB497716C4953174395D0A77FD1764B5A5AA624A98C61DBE37886CBD3CD9C602C829DD47B7ABE57AF0BFDDBC76D983C158720E68188C5CB5A16B7C5F0510AAF64F74727979BF536122D1AD9C7256207BE7629C9D74E9CE72ABA98605787515EE910B7F198E5062AA57A8E6466D079A44B78F11F5B2CE7A68831F892ED96F526B8F2B7B41F6A6FBBBCB7B040F9F44D9082AEFE6A0EA5905EB83C1A829F8224D731316C1D6E3D1159BE0FCFAD1B59C046603B594B56C31AD9F243B688D3177DD85CFB659667F5512FE6D25FA36CD3BE13D72044F5E63D8835B34BEF7CDC84E84D6DB8AE0C7F1B62CEE4A6EBC9F38D48BFA714EFE37C9AE67F65856BDBE098422A3FF43985D494A607159A88BE20C80F83B11F2F74E1E81FE39310F75ED2DBCD31B3EAD5437940671ECCE8BA76E827708C86EB45F0E66B5B0E5B27B4ECAD968CFDA1D62E6B3769650143CF5AB92D4DA7AD2EE379DE32E7ADAC3874E2829940D0C3393B9ABA4A65F4DC25B2DAFBE17BF6360EF6940B0F3D6BDB047DEAE5A7176FE038BD7D99896EAE7DAD46A29EC8988130328093CACCD5743F485E50D7D2A9BB693013DD6A7F37D285D8E2E4FA1076D1C810C802863606725B9A1A045DC6B4DE21394EE4F7F197B436434D6F12BA721A98CBAF3C6096E597C80ACE392ABF9799D778C68D61A6B59961CF336B22338B31A3B833C9EF0CDA6CC3E5EB2C0B96F7EB1C06EE13492D3FE87C529BD2685A9922FA9A5DEFC248F4F2B2E363B8BADA2C77E568B789A42974F541A46970E7D17995A5C2134A1DA21BB58034AB887CE6D4A232B79F5F75F39A4CAEAAF0E0334B1AEA46D38A0D157F73AAD67BC7214405EA3A0F7ADF746E19FE762FDA5F7EBF4FF7A3DD7AC92E8478362BB83DA9A77A994DB3224A2A6C3BD42CED2D46335331B88D686C1C7A3D36EA2584B178FB58BD59749C536E486978D52C951D1C35CD2F99B5E2CF37CC9DDF30170A6FB6E33E941C1C6E8DF7DC72E193DE74B772EDDB4C51BFBB8472B34CED0F8C1CF0EA6E6673BE02934DB5BDBD66A81398C1D65A1F214D9F936029DE3E343A1BA88B0E3AE7EB56349AF44AE9DE5C94A75F276FCEF14EA6CDB36E50CA18A2E95A3FEF4605F5E6F988E4215C0AF92013454AFEBF3EE838CA1ABF241105CAEF7DBC0C7913C60505A406BE6EA3B8ABEEBD8D57DB4D1853EF8FBC54F7F6F6562CB3F041C04F901C2D46F3D74C033D7806E78F3554DCE1E133A3889700E336519E808C3118C796D19E8898A9458E75F9BC8B0C0C01F407C68750F9D0E9E0250294F93A0DAA937EA2C62BC1EA5C578FD55A45884242C630E3DB468A62729EE7BCE39CB7468D9219D189E1277AD471DA2B95F2E6BDA508AF7F5DCDFCC6D1A5BA8031CCF83651A6908CBE667ABF2F3A7D3CC56C6C9BDA591232B414CD84CEB01E424C8DAA6CBB015EA8299DDB8B65D81F4D35360BFBD263B009FB86B43108B580DE1EABFBB827EF83EAE2F5D27A98E7A1967E9853FAE07CEB2B5EC483C3D7E2989A7D67219DFC1386739FED46CE6CDA4C3D0F6A2E8D8C1D7B8B657D3C3711CB6BE94C4BC7F0759A6E96E1BEFD5517A15F5850B5F3365ECD183FB750825CFAD1861CEAF94C0EB7B979CF5B7231FF8DA1775AF2A15FA6E4F2424395FE72AE2F121FE32B51B077CC4AC35570F5A4CB60656236D7D54AFD92AF2BA260270883E8321FE97CA50AE3CC5C84C278196E83C8DE07AD28B88291BFC950B4B2AE4F4FB9125B1117AB8D7D98BC34A4AE4F53A34D6BE70B097E342AADFCD51890F864D6475481DCF47CECB2E9B08D2A0F17B3634332B7471C34D14CD84EB8E68EAD9F66F580720B632A06382E7DEA116E00B9351FDF4CFA55A93A75D3333674F3FAC30111CDBBEA846DDE98FA69540FC8B65128615863F329996093DD2D3EB8B9844C934137B3433DC39B39AEA7806F834AAB01F4705EAD1E708F12733955FEE2ECECA551BF6F44634D75C1114574E80BE3D878BAB41362E61B1BF62DCEB903C35A0F38C7BD739D786D4236DEDD41B791B3F99A03EE3E3AA7653D79E934412DE53933D96A555FBD19D6F954B74ED36B78BCB33B3688DD678FB2CFD6F5847B307E87C21F1DC8A3A25C093B7383391902245573BC381C23A6A95E70C0825F803B03981AB7F64D1900AD9A19E58209634DE804B908F5027B31181F8AE11E710064B26A7844343CAABE9AD513BAE1B82A0A6B96002B15666A50A01BA8E9D8ACC9D863B21B3D1B6472EC26639129164636A07836D91B7E4FC32A33BA348859668CECC4ECB219A546418D0857530186994A1B96F128B7C9D861B40B3DDB6074AC26637FE13844167C38778AAD313AEDBB166B577ABE65B18EDF64EE576C149214B8587C922A8E55BE55372C73E82827E63B30BA3488EFC018D989F90E1099A30D6C0E986E82E513C2F0D8B07B029835F9CD503C116467129414421507B4E23C69BAF411E2136D3C0B0A30379A1B22D1C169D982BE308871769278B112786AC891996C1DA169A3FF644E819160D5D21B366650D64F77F05AC6D24F93FA42B3C92D45828B209AD260E5EC04D00455D3422DDA8F21F08A8ED954916A89F5B1508CF9C5291ECAA310A08D1CA5EEB13B24E1651B8CBA07EB589BD263645A83987A7B512A36AD716C3DA3DAC99D8AF1FBD4F3F1187F8C27734E06B1C658AF21A84214CA1B463D90D54DEA6E82D3931EAF2838E338899B0AA8230E6196BCE23D21FB74A22EDD7AE76232BD87DCF346DE67137B9C156E713F64296A0E348D9FA02B9CA47D1F4B1C106B2C2765E16D7C5A4E2073B3F15EF17D7A569ED9BD41CD3C73F4276AE7F9714468090AFF4D6235F08A2669D7C71057641DBB49D973B7F822B254E7D83D8D539531C51BB1C6737267290605950D61381F9509AE8A66CF1DC62897957CD82DD1668D15BF583F5867CCC48F6F34022E36723E1AD33B621BB8D3761232EF083E3DCFD9D6AF415D66DB088FDA577EBBE7B0CBCB6479099154CD795774ABE018DD278702FAB9BA2FA9A8884BD38A4451476721F95A642AE7592EEA6DCD9BA7B3D919000745ECEBC4C594D4751651D51084A0A0A32F649102D06541F240F63396E8F2B60F6CA4CA6F669166701F4112010A2B8B58D9A98024AAFE1EA38D47FC630D94CD15B375B450C80E320513A3A3F35B30FA2E9DB0629D570ED11922E5DD3C26533DB4610825A78EFA6481214D0E38C604AAB1E34CA19430BB1035FE0994A587AF7144560126A8BC3ADA87230C95C22B4EA05709E9E0C842157E8C3CB189A97D3D508EE476B36D92C5DC2191054CF196D90A5E7B3145DB662D7CDCCA144ECE5EF3308029753F3E94C4CAA5D5C4494E89B1CA2B74B93329A7BADAE3ACBA8A874CF1EAD69D929D14C3F7A2651D1C6C5356E5ADE80EB2DA75865AAC7CAD808EDC385E954EB2595EA51EC3EE10A14936AFAB51C9D178B556AC85221450AB0BA9A8D25F26ADA8D45BC8712314CA2412952AD05CB8D6DA04F6413675DA8AE0DDB59484140A3A8584466D550CAB528309D14DBD349122570F289562376A47C913DDAAF33B10B80DB6176AA405DC0A7B54356E85CD2D90173B4C93C021A6D88139CE30963CEE38CD207335CB678BEB1CBA28D318A2537BB4A3D15332D651D3A0EA3D5B544846354A8265D7D6BBC2F4B307BBDAA837A7641F91C7A7BE54883C3EE563BCA136911FAD8315C988C8323A49C76369FDD3365916FDD191575D6290A2F7E1E8CE09851C4E207F7A1C0A88661408A2484BB888D13B3C5844EB138E1286CC3E5007071DD8D4E4B00BA2E3133CA8AB6F27DD46A781E88ECDC061F494C3C1A1E9513B6BB5A892C3BAD1F95C85D81B0855BAABD041753C950DA32A933400D292855A40ED0F4E2E2077453DD5A6F483D309E8F2BC69047BC28EE986F5E4DDEC95EDD1BBDE3FE562C1A632DB3377EE6034D5A1F9701AD39EE589B5D935FC91B5DE29C6F4A39F55F7A725FC2480F1BA97EA12BEE36FA6227C73AF5D0F793B37713B656594B21F6AB89DB66277478CD393719CBA72B7F8647E7B67B95B7DF8B28CA1CD41B6FC50E5BC53286649B77EF3CEA3BCA878C89329E83693855DD72302B21CA55AFE1697AEA22FFCDA5E007175DA08C1DCE743FEF53C0610B38E16F0CCF61EB38E18A0BB7E8636FB3F6A306AE6FA04AE470E64B92E5438940360FEB833AE443A0A1FEC1F1A870F74ED1013C2501B1A792F3BA5728090677DB919495E2C38D15137B3E8ACC73E0CE1E1D7AFEBC8E13AED7C71BDBC17EBA0FA70BEC8B32CC536DB05D1871CEC517A48F8106CB7617C971E4B565F66D7DBBC1B17F3CBDF5ECF678FEB284E2FE6F759B67DB558A47BD1E9D93A5C269B74739B9D2D37EB45B0DA2CBE7DF1E20F8B972F17EB52C662A9ECACF438E7BAA66C93E4DB402DB5FCF1FA776192665741167C0D8A5F61BF5CAD8D6CEF223D4E1A09973AD4A785429B237A089F3A1428FEFF1893BD3FE74ACF8A46D541D39A8CA31ADFE53D2B8E0DF69D1466609259322F7BBD0CA220399831B5BD4548FAE526DAAD63E3B38E4D5C56190C288B81C2032909FF108126A1FCC29770D8A2CB32E0684786560E3FE20D6806FB7D6F5C663EB2426B58F5C99471BED0065A47D3C2809336BB7578BA80B70C6BF3006028708F0F62B8749F4356C627CAA2A00708E4A08B749984DB72D951865E4E180D002497A8CDF0634E2F63ECF1A2988AE5D7BCB286A957BEB8B4E25F554EF9852FE1E720DA6922AA4F5D006F20A080E1A06D2003BDA371470F4B0ABA749885754C2159FA84D7DF8375F4F831D41A76FCCA97F4439066D7C183587DD46C9392C09777791FC47762F5E64995267D7658C6A54860781070B2C48127457DB8DE7E3AC0D708EC798015EF46E9DD7A64135B4881D8EE3670309FEFB9638221035D8EF4A23A3AC00C0ECBDDBEF84A5FF2EAAF0E92C22CD2C5949FBA871A6A1783F88D28A22D44F5CA4DB18E7AA2C326A50AE0A86E07158F574DE2CB7C9DA6E15D2C569F37805423D1616B189AE37BF8E63232B7C12ECA3E8934FF571F1B25892F533EADD361ADA78DC6BCA8478C6D2C0B75C8CA302A74F16E748ECE330361EEF89ADC22231FF1B55D61F0E34EE6F24209A06CBF4A8DA0AF013471022DD97094EB8FAEAB5392888858FB94E421563E3F16768CEB671756FFEDE3364C9E8AF33755A0FCDD61D55C16A7E0E6464AFEEE2E4DDF48C9DF5DACE27A5BF0BA188D53125C5B671EF5CADFC7E11B95A5A0ED8799EAEE2FE0360BCE319A5503BA1CF2E141B45A3D3842BA1F115B0DC66AA2240C37277314278034E9B383B5DDAC835037DCD537778DE90F3AB19181F2F5E5C3DBA4C2072266EAE866B8979328FA41ABC3D4763D8D6AAFFEE713296DB3A00412B6DD2DC8F427CDB60BA404CA63960A42DEB896CC1F52BF5749ED77360342450DD86B8B1585CEA619586811E41E502A098D829EFE8C970678F17473AC708C35038AFB0DB25C0A527BF3E1F4B3B5F70BB3491E789A4F1CDBA24C219E6B86345A04850BB92484383DBDCF18ACF7F19754036DF5E95762CACACB0D1FF86A812B773C61387AC64F9FF8D1DF80B682914643D9004D3609E800A8058D113093F983FB2E8CF61D56451EBFF2257D0C57579BE5AEE4E8948529090EB0D37E28D6E832F123B2C342AE7EF3DA1A6FC8FB5E2ED8D0E2DDE81C935ABF6796C5210CAC949C77C966ADE174FFC505537A9F9C9CB57BA19D2E945F1CCC715A71062806F9F0D1716E800334BED9E0611A34C5BF23F01D14DAE5955D11F157C5E999A18075C2B806D9CBE926F15A9F3BE2AEE79ADA4F3D1BA3FF7CA2E982020FCE7ACD63DD10008EEEFAA10838F84338ECDDACC06D603E14A0A46788AD10853EBBE4408A288CEA5AF9311D45D5E4CFEC10127F6D2F5F107A101F37676D03779972ECE77D44002F9AC9610D12C943B814F23B5B653932939D657F492250E8FE3B5FDA9B305EE50AD77E1C40960BE7706EEFDB78B5DD84FAE6D44874085BBABD15CB2C7C1040E4929A345428D4244F9741A2151F53BFDD1D294B8A6D2088BB5224CBD01713938FACF277770A496C01A46677A850696C64C672977A3258F274AFAA9398B40091FBFDAA5E120D026B34D47E03D6FC86903503F5C090AB48497CC0ADFC69A0E65843CADB06715F0C1BC53AB1CF53D8F6BBF4F26739F5986B57C7140AA2778F9E6FFFD2C6D7F97CF7B1BFCDF7D69D4E6383A447CF52D75E7DA9FFAE497A2A821C85B967AF85828767DFFBB422EBD11973CA2CF359AEAA877055B0E55C3FA59958576F97FF195D46E1FEEAED90E1431087B722CD3E6F7E11F1C5FCDB172F7E3F9FBD8EC2202DF9972A2EA057FA2F91B2C8815E7E57900389D57AA11777A7182AA4A4E92A0208868A613ABC2E805876CEFF2A9EF4113E60E9F86BB028B1CEF9422F7FAE21512A5AFE0ADB7EF3B8379D7F163902F29DDAEAA720CB3DAF5C6FEF8B5F920D0B92BA1F7751147C2DA8A46E83C8BC86D76B29ED525941FC1024CBFB8280E743F0F88388EFB2FB8BF9CBDFC932F7BF0E6B115972F8486D766CD2E1249B6A94B3508D14466A9DF173B8EFE39578BC98FFD7BEE4ABD9FBBFDF2885BF997D4C728CBF9ABD98FDB773332A0A20A26B39342D526543C2C1AD49ACE3845D9847878D5F40E3BE315C9E55923A751F28F9D8923F5CE6FC608F16EC68F3860A7730EDE32497ED70908A7F5B02DF145A31EDB4199FD6706A31E456FE1ADEE8B3686AEC4040C48C08139CD13B52E394727771F8CF9D08F74DBC0D8BC5CEB1910A3D4E297395773F0B8BB63BCA92C871BC2EB93A5D8BDBF2A6967658DF1C810E5D9DBB201CBB43E4421BD48F6F4C33BC97492C4716FE18DEB8318862EC83070AE9D29DA863F65BAC0180D8324AC7AFB5E3E2E27B77D1C673EC52FCD7D0DDA3D7F869FCAAC0A0A9F12BFE40AAE0150B1A918157D9FAF1A5DB5AA096EE622DC039647836853E9EB59B13423FBE2D891539DF4F6525C01EEAF39701EA408EB706A8123A5E007C7A9000654CF3D311D6EAD400572C3BE72E766AAB5E9796590EB1C03712AC354F629AF123C9FB9644E1B6F0D1C60E4E2A3DBB382AC74C278B3A6A031D96765946970B7CBB35837391C35FEC7B5B3B148A184FEB87C7A92471C4B43CCA38DCB9B35721179843FC30CDC06E4AC2203F62DF1A6F48D3231FBD7C9776A0F9B18F8DF5853FFF9F8F7E1C1D7E340891EFF19371863C975F13D1E1D821B7208CA9742CD96A46933B1C4633F4F25DCC689A98858F0C3A6C90070D5DC6333686C7469B2B4C9A798587899EAE321B1C104F0367633F3AA45958F838A3F9567858D3658C27468725B3E2E868BEE19D8A4D329F6BBAE1A40D3E9E7131525C503C294C78D828511828314574089623E18ADFB358857BC5D781B9F60CD911414AE9CEF003529F3880077D66CD440EAC1FDFB0A983B4FD1EB397B42A7EEFD737BEA15D46FDB73C27ABB9575A98D4034B488379D0E104688CFCC690EFDAAFEFE2AE4AA15471C292DB68343F6523F9199823F37CBEE63A5E8DFD529C3784395613F54C07720A5C00CF6D4797A7EE18A108135DC4232706BC94D25D5A6AB710ED91DA0106D3876B4854CB504B54509756DD640A51B5FF1FEBE0F13F9D2F3A25AA106A30BF770E1A80C942BC5E831A94215EA56BD4212DFD5B7F412D633F7DB4F273B84DD696D763889853BE069962104CDBEB321ED3061F2EBFA66BB329E2A5CD159A9D58838F939EAED23A8D221A3C4AA7E719E00C36806FC30D6908B9061F66B5802E43F27C1CE375107D7AA0F3F07A0ADA49E072072F603A3A571E81C977D81673CE0BA4B21E4CC1EB34DD2CC37D6555E3AA67FA37385940BE0D997DDA44422514A8FA51D0799C29DF3FE4F80BB751B8CCAB2F981A746BF231BE124534EBACC47F11859D2E03934FA6E8C2CAD212A8157A0B7E6308CEED9828A242C320CA77716996E44B90C1D6F25312C6CB701B4440DFB5BCA08924D9138ADED515E82957622BE2C2D8697DF5526B2D5CD3B54D27E70B093A34A28077E437C403E0E3A02A99E49155137A0118F434DF6C9296DE09F070D52118A01F4B3B41CF4A50D0B8093DE0D07837ACB876280A954CF290AB09BDA0D07C842D370848ED0481B8DA90E1B731E83920D0F20CBD71037AC09FE9474C0F80C05B1EA84572F2C94190F58BD7D3C3A0FE32C68AC7C618787176F6D2800125BFE4881B12670DC79A661D6C85B9BD4E5CDAC2F98DEDA131687108B56C10227A750AC7660D1D9C42FB0F68F7671147E0170258ECC31276E826226DD2934EDA6A524C152DDBD0132EA5DBBCFA0C1885639D411EF0E3C7DEA0275F88EAD853D23A011FAC2664B8F1AB1167A0D13FF6E05AF500F822795D3C189793455C033363FF0DDB8ED1C769404F1894AFA0A763E4948B7C1D736AE2499939CB6F918CD4CE29189BB0A11B1A75633075CE081C91AD3B346E3A760E6C879A7052F6CD63BD7D636A72A7C943E26BE84B0C279C8DE2EC587FE53EE57554610DD05BA4269EEC3A8A3327B468418F389C3AFE40DC9D38DE268533E989D80DF4C2551A52F9496F399EE5977E00253F3F371A512774032C532FD8A8C24F7DDD60843EB477AFB42F041D191D6E089E8096A3D925B224620CA339725A77F8721E71E227EB5DD186D18234AEBE2FDC954BE4241167AE8EC7AFA78932FEDA38427C596EEDE53CC6A0F67A5F3F20B81CAEE649FE85AEA135F05D3CF8E0787A071BF04B6EB851A71DAFC978D3DEB8113DE27172F7F0D0E364087FA7791F6F7D9ADDA8FA81F076020149E341E35842939A227444F149D013F2691947F43615CE7072E6717A77F920E64EC8408E0191633391CE281DA18D9CD6BDBF413E0121F104EFFF69D28D46750F81B1C96E9787C4DB1836C9D38B0950783B247202FC30F098453983933EF70AB992F204C25B95D2CD9120A22864A82916C6464003885E1A56DD3BC64EC8D91B067B6373EFF8581CCCAF2BB953F232595E4224120BCEBB3049B3AB200BBE06A9B9D616A5AE45A67271CC67472A169DA9E47A792FD6C1C57CF5B5202F2FD95CEA44E3C12C28BE245DC1AA2853896ACA0C96AA8E4BB151CF3109AAE4986AA901A4D3302A037341F58219594D38DC4F21751F92F14A0F392CB501DC0D4695401EA85E209BA572D5E533EA5593A12AD51C8CAECA3617ECA79C01EBA49C87D943B25E2813D5DB06F5A370D23350F53A404A39500515ADE4C034AD646254AB9E5280F5AA59B08AD55C8C9A09D3A4266335B24D9419290AD6A866C16A5573316B266AA46BB2D7A0C7F69815E939C0FAF44C9C6AEB7813B8CE3A19ADB0CEC1A90DAB8690CF138CCE742515AD843BC78FB10B704504188EC9B64AA4CD99598B94085623A5B397217A1D44F2D10B5393F590B69E602EAA112E56143EEF45DB60B7A6704E662B08AB6A66A16A675B576D2784565BA553755659B40A2557DFF0A115F2C399945375A6718E4465BB0738E6798DA4C70D9587CA9ADB4EB55B8C2E5BD9F980FEBB31FA299D81BCEA7D8F286F199000DA0849103DE1DDD564218F0394E44237479CCC4A3DA3BC6CF5900DDB4CECC5D8F707EEEA21387D30FDD88A74A9207C3BA0C8211C7CAF2A32A8B7DCD4453377F9EDB8455AC9D435A02A71A3652F64EF2860B7E84DD9E0A8B3931B21A6CB8111A94384C16705B519F3AE2A30CE0FD1903D2610B9D8953A81F94386120057B4D602E557B65783AE67BB32E8C7663E467760F5C0114F886618E1511E7102ED176A4D90BEBF0755F0A0C2E6E2E8082B7DABC88CFD4014630912F18812B03479FAD5B2EB1C679911BFD0819FDC972AA897F38842D88FED3B9A28D0E9662D873CB16CAE2207D50CA51250153E5460BE37867A6F7995AC36593EE22CDB0B9D609A65B443D86351EC70B56177B1C7B158C7598F69DB77C794601E861F851027DC0DD562BEDDC4146279E5D9852ACC39809E24B7EE3EBE9D63BC41349B0EECDF88D3F69EBBCE78FB466C6B073A6A22CFEC3551DD1C3971B76CFCA75C9E1C2DE21641518CDFFD09F305115341036EFD87551F7B8BE7F00AC633AED07D0CEBAAC7936ADCA0E5F46CA3076C0DA542D69690F976C033AA4009D6EB3B0FAAE02E74FD6F1387528D11544D68850EC0563D19E33ABF7465D08B7A5019CAC5ACA209F8BEB5AD1ADC0C0D2F56B8070BE34F4D879FF0ABC350EBB4F34579FD5D7DC8FFCC3649EECA7FC8811DA5FBAFE78B4FBBB8F8A1CBF2AF2B9186774711E7B9CC58EC239A8F420F79DEC7B79B03B8B5161DB21C92AB81FB20B2601564C1EB240B6F836596272FF3CD4518DFCD673F07D12ECFF276FD55ACDEC7B979DDEEB2BCCB62FD3552A64E11C54BD57FBE30DA7CFE715BFC95FAE842DECCB0F86DD08FF19B5D18ADEA76BF037E5A1111519895EA574B8BB1CC8A5F2FBD7BAA25FDB88999822AF5D551CD9FC57A1BE5C2D28FF175F0209AB42DDFB1FC20EE82E553FEFD215C156B1B26C43E10AADACFAFC2E02E5F31D34AC6B17CFE678EE1D5FAF18FFF0FD13FB5ADF9DF0100 , N'6.1.1-30610')


exec sp_executesql N'INSERT [dbo].[HolidayType]([Type], [Description])
VALUES (@0, @1)
SELECT [HolidayTypeId]
FROM [dbo].[HolidayType]
WHERE @@ROWCOUNT > 0 AND [HolidayTypeId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'Public',@1=N'Public holiday'
go
exec sp_executesql N'INSERT [dbo].[HolidayType]([Type], [Description])
VALUES (@0, @1)
SELECT [HolidayTypeId]
FROM [dbo].[HolidayType]
WHERE @@ROWCOUNT > 0 AND [HolidayTypeId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'Annual',@1=N'Annual leave'
go
exec sp_executesql N'INSERT [dbo].[HolidayType]([Type], [Description])
VALUES (@0, @1)
SELECT [HolidayTypeId]
FROM [dbo].[HolidayType]
WHERE @@ROWCOUNT > 0 AND [HolidayTypeId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'Sick',@1=N'Sick leave'
go
exec sp_executesql N'INSERT [dbo].[Holiday]([User], [Year], [Status], [HolidayTypeId], [Dates])
VALUES (NULL, @0, @1, @2, @3)
SELECT [HolidayId]
FROM [dbo].[Holiday]
WHERE @@ROWCOUNT > 0 AND [HolidayId] = scope_identity()',N'@0 int,@1 nvarchar(1),@2 int,@3 nvarchar(200)',@0=2014,@1=N'A',@2=1,@3=N'01/01/2014,27/01/2014,25/04/2014,09/06/2014,06/10/2014,25/12/2014,26/12/2014'
go
exec sp_executesql N'INSERT [dbo].[Holiday]([User], [Year], [Status], [HolidayTypeId], [Dates])
VALUES (NULL, @0, @1, @2, @3)
SELECT [HolidayId]
FROM [dbo].[Holiday]
WHERE @@ROWCOUNT > 0 AND [HolidayId] = scope_identity()',N'@0 int,@1 nvarchar(1),@2 int,@3 nvarchar(200)',@0=2015,@1=N'A',@2=1,@3=N'01/01/2015,26/01/2015,25/04/2015,08/06/2015,05/10/2015,25/12/2015,28/12/2015'
go
exec sp_executesql N'INSERT [dbo].[Holiday]([User], [Year], [Status], [HolidayTypeId], [Dates])
VALUES (NULL, @0, @1, @2, @3)
SELECT [HolidayId]
FROM [dbo].[Holiday]
WHERE @@ROWCOUNT > 0 AND [HolidayId] = scope_identity()',N'@0 int,@1 nvarchar(1),@2 int,@3 nvarchar(200)',@0=2016,@1=N'A',@2=1,@3=N'01/01/2016,26/01/2016,25/04/2016,13/06/2016,03/10/2016,26/12/2016,27/12/2016'
go
exec sp_executesql N'INSERT [dbo].[SketchStatus]([Status], [Description])
VALUES (@0, @1)
SELECT [SketchStatusId]
FROM [dbo].[SketchStatus]
WHERE @@ROWCOUNT > 0 AND [SketchStatusId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'Aborted',@1=N'Abort workflow deployment'
go
exec sp_executesql N'INSERT [dbo].[SketchStatus]([Status], [Description])
VALUES (@0, @1)
SELECT [SketchStatusId]
FROM [dbo].[SketchStatus]
WHERE @@ROWCOUNT > 0 AND [SketchStatusId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'DeployedDev',@1=N'Deployed to dev'
go
exec sp_executesql N'INSERT [dbo].[SketchStatus]([Status], [Description])
VALUES (@0, @1)
SELECT [SketchStatusId]
FROM [dbo].[SketchStatus]
WHERE @@ROWCOUNT > 0 AND [SketchStatusId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'DeployedProd',@1=N'Deployed to prod'
go
exec sp_executesql N'INSERT [dbo].[SketchStatus]([Status], [Description])
VALUES (@0, @1)
SELECT [SketchStatusId]
FROM [dbo].[SketchStatus]
WHERE @@ROWCOUNT > 0 AND [SketchStatusId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'Saved',@1=N'Sketch Saved'
go
exec sp_executesql N'INSERT [dbo].[SketchStatus]([Status], [Description])
VALUES (@0, @1)
SELECT [SketchStatusId]
FROM [dbo].[SketchStatus]
WHERE @@ROWCOUNT > 0 AND [SketchStatusId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'SentToSketch',@1=N'Sent To Sketch'
go
exec sp_executesql N'INSERT [dbo].[TopicStatus]([Status], [Description])
VALUES (@0, @1)
SELECT [TopicStatusId]
FROM [dbo].[TopicStatus]
WHERE @@ROWCOUNT > 0 AND [TopicStatusId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'New',@1=N'New topic message'
go
exec sp_executesql N'INSERT [dbo].[TopicStatus]([Status], [Description])
VALUES (@0, @1)
SELECT [TopicStatusId]
FROM [dbo].[TopicStatus]
WHERE @@ROWCOUNT > 0 AND [TopicStatusId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'Read',@1=N'Read topic message'
go
exec sp_executesql N'INSERT [dbo].[TraceEvent]([Type], [Description])
VALUES (@0, @1)
SELECT [TraceEventId]
FROM [dbo].[TraceEvent]
WHERE @@ROWCOUNT > 0 AND [TraceEventId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'Debug',@1=N'Debug'
go
exec sp_executesql N'INSERT [dbo].[TraceEvent]([Type], [Description])
VALUES (@0, @1)
SELECT [TraceEventId]
FROM [dbo].[TraceEvent]
WHERE @@ROWCOUNT > 0 AND [TraceEventId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'Activity',@1=N'Activity'
go
exec sp_executesql N'INSERT [dbo].[TraceEvent]([Type], [Description])
VALUES (@0, @1)
SELECT [TraceEventId]
FROM [dbo].[TraceEvent]
WHERE @@ROWCOUNT > 0 AND [TraceEventId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'Error',@1=N'Error'
go
exec sp_executesql N'INSERT [dbo].[TraceEvent]([Type], [Description])
VALUES (@0, @1)
SELECT [TraceEventId]
FROM [dbo].[TraceEvent]
WHERE @@ROWCOUNT > 0 AND [TraceEventId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'Info',@1=N'Info'
go
exec sp_executesql N'INSERT [dbo].[WorkflowCode]([Code], [Description])
VALUES (@0, @1)
SELECT [WorkflowCodeId]
FROM [dbo].[WorkflowCode]
WHERE @@ROWCOUNT > 0 AND [WorkflowCodeId] = scope_identity()',N'@0 nvarchar(50),@1 nvarchar(200)',@0=N'SampleWf1',@1=N'this is a sample wf code for testing (1)'
go
exec sp_executesql N'INSERT [dbo].[WorkflowCode]([Code], [Description])
VALUES (@0, @1)
SELECT [WorkflowCodeId]
FROM [dbo].[WorkflowCode]
WHERE @@ROWCOUNT > 0 AND [WorkflowCodeId] = scope_identity()',N'@0 nvarchar(50),@1 nvarchar(200)',@0=N'SampleWf2',@1=N'this is a sample wf code for testing (2)'
go
exec sp_executesql N'INSERT [dbo].[WorkflowCode]([Code], [Description])
VALUES (@0, @1)
SELECT [WorkflowCodeId]
FROM [dbo].[WorkflowCode]
WHERE @@ROWCOUNT > 0 AND [WorkflowCodeId] = scope_identity()',N'@0 nvarchar(50),@1 nvarchar(200)',@0=N'SampleWf3',@1=N'this is a sample wf code for testing (3)'
go
exec sp_executesql N'INSERT [dbo].[WorkflowCode]([Code], [Description])
VALUES (@0, @1)
SELECT [WorkflowCodeId]
FROM [dbo].[WorkflowCode]
WHERE @@ROWCOUNT > 0 AND [WorkflowCodeId] = scope_identity()',N'@0 nvarchar(50),@1 nvarchar(200)',@0=N'SampleWf4',@1=N'this is a sample wf code for testing (4)'
go
exec sp_executesql N'INSERT [dbo].[WorkflowCode]([Code], [Description])
VALUES (@0, @1)
SELECT [WorkflowCodeId]
FROM [dbo].[WorkflowCode]
WHERE @@ROWCOUNT > 0 AND [WorkflowCodeId] = scope_identity()',N'@0 nvarchar(50),@1 nvarchar(200)',@0=N'SampleWf4a',@1=N'this is a sample wf code for testing (4a)'
go
exec sp_executesql N'INSERT [dbo].[WorkflowCode]([Code], [Description])
VALUES (@0, @1)
SELECT [WorkflowCodeId]
FROM [dbo].[WorkflowCode]
WHERE @@ROWCOUNT > 0 AND [WorkflowCodeId] = scope_identity()',N'@0 nvarchar(50),@1 nvarchar(200)',@0=N'SampleWf5',@1=N'this is a sample wf code for testing (5)'
go
exec sp_executesql N'INSERT [dbo].[WorkflowCode]([Code], [Description])
VALUES (@0, @1)
SELECT [WorkflowCodeId]
FROM [dbo].[WorkflowCode]
WHERE @@ROWCOUNT > 0 AND [WorkflowCodeId] = scope_identity()',N'@0 nvarchar(50),@1 nvarchar(200)',@0=N'SampleWf6',@1=N'this is a sample wf code for testing (6)'
go
exec sp_executesql N'INSERT [dbo].[WorkflowCode]([Code], [Description])
VALUES (@0, @1)
SELECT [WorkflowCodeId]
FROM [dbo].[WorkflowCode]
WHERE @@ROWCOUNT > 0 AND [WorkflowCodeId] = scope_identity()',N'@0 nvarchar(50),@1 nvarchar(200)',@0=N'SampleWf7',@1=N'this is a sample wf code for testing (7)'
go
exec sp_executesql N'INSERT [dbo].[WorkflowCode]([Code], [Description])
VALUES (@0, @1)
SELECT [WorkflowCodeId]
FROM [dbo].[WorkflowCode]
WHERE @@ROWCOUNT > 0 AND [WorkflowCodeId] = scope_identity()',N'@0 nvarchar(50),@1 nvarchar(200)',@0=N'SampleWf8',@1=N'this is a sample wf code for testing (8)'
go
exec sp_executesql N'INSERT [dbo].[WorkflowCode]([Code], [Description])
VALUES (@0, @1)
SELECT [WorkflowCodeId]
FROM [dbo].[WorkflowCode]
WHERE @@ROWCOUNT > 0 AND [WorkflowCodeId] = scope_identity()',N'@0 nvarchar(50),@1 nvarchar(200)',@0=N'SampleWf9',@1=N'this is a sample wf code for testing (9)'
go
exec sp_executesql N'INSERT [dbo].[WorkflowConfiguration]([ServiceDefinition], [ServiceUrl], [BindingConfiguration], [ServiceEndpoint], [EffectiveDate], [ExpiryDate], [WorkflowCodeId])
VALUES (NULL, @0, @1, @2, @3, NULL, @4)
SELECT [WorkflowConfigurationId]
FROM [dbo].[WorkflowConfiguration]
WHERE @@ROWCOUNT > 0 AND [WorkflowConfigurationId] = scope_identity()',N'@0 nvarchar(256),@1 nvarchar(50),@2 nvarchar(50),@3 datetime2(7),@4 int',@0=N'http://localhost/Flow.Tasks.Workflows/SampleWf1.xamlx',@1=N'BasicHttpBinding_FlowTasks',@2=N'BasicHttpBinding_IFlowTasksOperations1',@3='2014-05-14 22:29:06.2751714',@4=1
go
exec sp_executesql N'INSERT [dbo].[WorkflowConfiguration]([ServiceDefinition], [ServiceUrl], [BindingConfiguration], [ServiceEndpoint], [EffectiveDate], [ExpiryDate], [WorkflowCodeId])
VALUES (NULL, @0, @1, @2, @3, NULL, @4)
SELECT [WorkflowConfigurationId]
FROM [dbo].[WorkflowConfiguration]
WHERE @@ROWCOUNT > 0 AND [WorkflowConfigurationId] = scope_identity()',N'@0 nvarchar(256),@1 nvarchar(50),@2 nvarchar(50),@3 datetime2(7),@4 int',@0=N'http://localhost/Flow.Tasks.Workflows/SampleWf2.xamlx',@1=N'BasicHttpBinding_FlowTasks',@2=N'BasicHttpBinding_IFlowTasksOperations2',@3='2014-05-14 22:29:06.2761714',@4=2
go
exec sp_executesql N'INSERT [dbo].[WorkflowConfiguration]([ServiceDefinition], [ServiceUrl], [BindingConfiguration], [ServiceEndpoint], [EffectiveDate], [ExpiryDate], [WorkflowCodeId])
VALUES (NULL, @0, @1, @2, @3, NULL, @4)
SELECT [WorkflowConfigurationId]
FROM [dbo].[WorkflowConfiguration]
WHERE @@ROWCOUNT > 0 AND [WorkflowConfigurationId] = scope_identity()',N'@0 nvarchar(256),@1 nvarchar(50),@2 nvarchar(50),@3 datetime2(7),@4 int',@0=N'http://localhost/Flow.Tasks.Workflows/SampleWf3.xamlx',@1=N'BasicHttpBinding_FlowTasks',@2=N'BasicHttpBinding_IFlowTasksOperations3',@3='2014-05-14 22:29:06.2761714',@4=3
go
exec sp_executesql N'INSERT [dbo].[WorkflowConfiguration]([ServiceDefinition], [ServiceUrl], [BindingConfiguration], [ServiceEndpoint], [EffectiveDate], [ExpiryDate], [WorkflowCodeId])
VALUES (NULL, @0, @1, @2, @3, NULL, @4)
SELECT [WorkflowConfigurationId]
FROM [dbo].[WorkflowConfiguration]
WHERE @@ROWCOUNT > 0 AND [WorkflowConfigurationId] = scope_identity()',N'@0 nvarchar(256),@1 nvarchar(50),@2 nvarchar(50),@3 datetime2(7),@4 int',@0=N'http://localhost/Flow.Tasks.Workflows/SampleWf4.xamlx',@1=N'BasicHttpBinding_FlowTasks',@2=N'BasicHttpBinding_IFlowTasksOperations4',@3='2014-05-14 22:29:06.2761714',@4=4
go
exec sp_executesql N'INSERT [dbo].[WorkflowConfiguration]([ServiceDefinition], [ServiceUrl], [BindingConfiguration], [ServiceEndpoint], [EffectiveDate], [ExpiryDate], [WorkflowCodeId])
VALUES (NULL, @0, @1, @2, @3, NULL, @4)
SELECT [WorkflowConfigurationId]
FROM [dbo].[WorkflowConfiguration]
WHERE @@ROWCOUNT > 0 AND [WorkflowConfigurationId] = scope_identity()',N'@0 nvarchar(256),@1 nvarchar(50),@2 nvarchar(50),@3 datetime2(7),@4 int',@0=N'http://localhost/Flow.Tasks.Workflows/SampleWf4a.xamlx',@1=N'BasicHttpBinding_FlowTasks',@2=N'BasicHttpBinding_IFlowTasksOperations4a',@3='2014-05-14 22:29:06.2761714',@4=5
go
exec sp_executesql N'INSERT [dbo].[WorkflowConfiguration]([ServiceDefinition], [ServiceUrl], [BindingConfiguration], [ServiceEndpoint], [EffectiveDate], [ExpiryDate], [WorkflowCodeId])
VALUES (NULL, @0, @1, @2, @3, NULL, @4)
SELECT [WorkflowConfigurationId]
FROM [dbo].[WorkflowConfiguration]
WHERE @@ROWCOUNT > 0 AND [WorkflowConfigurationId] = scope_identity()',N'@0 nvarchar(256),@1 nvarchar(50),@2 nvarchar(50),@3 datetime2(7),@4 int',@0=N'http://localhost/Flow.Tasks.Workflows/SampleWf5.xamlx',@1=N'BasicHttpBinding_FlowTasks',@2=N'BasicHttpBinding_IFlowTasksOperations5',@3='2014-05-14 22:29:06.2761714',@4=6
go
exec sp_executesql N'INSERT [dbo].[WorkflowConfiguration]([ServiceDefinition], [ServiceUrl], [BindingConfiguration], [ServiceEndpoint], [EffectiveDate], [ExpiryDate], [WorkflowCodeId])
VALUES (NULL, @0, @1, @2, @3, NULL, @4)
SELECT [WorkflowConfigurationId]
FROM [dbo].[WorkflowConfiguration]
WHERE @@ROWCOUNT > 0 AND [WorkflowConfigurationId] = scope_identity()',N'@0 nvarchar(256),@1 nvarchar(50),@2 nvarchar(50),@3 datetime2(7),@4 int',@0=N'http://localhost/Flow.Tasks.Workflows/SampleWf6.xamlx',@1=N'BasicHttpBinding_FlowTasks',@2=N'BasicHttpBinding_IFlowTasksOperations6',@3='2014-05-14 22:29:06.2761714',@4=7
go
exec sp_executesql N'INSERT [dbo].[WorkflowConfiguration]([ServiceDefinition], [ServiceUrl], [BindingConfiguration], [ServiceEndpoint], [EffectiveDate], [ExpiryDate], [WorkflowCodeId])
VALUES (NULL, @0, @1, @2, @3, NULL, @4)
SELECT [WorkflowConfigurationId]
FROM [dbo].[WorkflowConfiguration]
WHERE @@ROWCOUNT > 0 AND [WorkflowConfigurationId] = scope_identity()',N'@0 nvarchar(256),@1 nvarchar(50),@2 nvarchar(50),@3 datetime2(7),@4 int',@0=N'http://localhost/Flow.Tasks.Workflows/SampleWf7.xamlx',@1=N'BasicHttpBinding_FlowTasks',@2=N'BasicHttpBinding_IFlowTasksOperations7',@3='2014-05-14 22:29:06.2761714',@4=8
go
exec sp_executesql N'INSERT [dbo].[WorkflowConfiguration]([ServiceDefinition], [ServiceUrl], [BindingConfiguration], [ServiceEndpoint], [EffectiveDate], [ExpiryDate], [WorkflowCodeId])
VALUES (NULL, @0, @1, @2, @3, NULL, @4)
SELECT [WorkflowConfigurationId]
FROM [dbo].[WorkflowConfiguration]
WHERE @@ROWCOUNT > 0 AND [WorkflowConfigurationId] = scope_identity()',N'@0 nvarchar(256),@1 nvarchar(50),@2 nvarchar(50),@3 datetime2(7),@4 int',@0=N'http://localhost/ServiceWorkflowsVB/SampleWf8.xamlx',@1=N'BasicHttpBinding_FlowTasks',@2=N'BasicHttpBinding_IFlowTasksOperations8',@3='2014-05-14 22:29:06.2761714',@4=9
go
exec sp_executesql N'INSERT [dbo].[WorkflowConfiguration]([ServiceDefinition], [ServiceUrl], [BindingConfiguration], [ServiceEndpoint], [EffectiveDate], [ExpiryDate], [WorkflowCodeId])
VALUES (NULL, @0, @1, @2, @3, NULL, @4)
SELECT [WorkflowConfigurationId]
FROM [dbo].[WorkflowConfiguration]
WHERE @@ROWCOUNT > 0 AND [WorkflowConfigurationId] = scope_identity()',N'@0 nvarchar(256),@1 nvarchar(50),@2 nvarchar(50),@3 datetime2(7),@4 int',@0=N'http://localhost/ServiceWorkflowsVB/SampleWf9.xamlx',@1=N'BasicHttpBinding_FlowTasks',@2=N'BasicHttpBinding_IFlowTasksOperations9',@3='2014-05-14 22:29:06.2761714',@4=10
go
exec sp_executesql N'INSERT [dbo].[WorkflowStatus]([Status], [Description])
VALUES (@0, @1)
SELECT [WorkflowStatusId]
FROM [dbo].[WorkflowStatus]
WHERE @@ROWCOUNT > 0 AND [WorkflowStatusId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'Completed',@1=N'Completed'
go
exec sp_executesql N'INSERT [dbo].[WorkflowStatus]([Status], [Description])
VALUES (@0, @1)
SELECT [WorkflowStatusId]
FROM [dbo].[WorkflowStatus]
WHERE @@ROWCOUNT > 0 AND [WorkflowStatusId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'Aborted',@1=N'Aborted'
go
exec sp_executesql N'INSERT [dbo].[WorkflowStatus]([Status], [Description])
VALUES (@0, @1)
SELECT [WorkflowStatusId]
FROM [dbo].[WorkflowStatus]
WHERE @@ROWCOUNT > 0 AND [WorkflowStatusId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'InProgress',@1=N'InProgress'
go
exec sp_executesql N'INSERT [dbo].[WorkflowStatus]([Status], [Description])
VALUES (@0, @1)
SELECT [WorkflowStatusId]
FROM [dbo].[WorkflowStatus]
WHERE @@ROWCOUNT > 0 AND [WorkflowStatusId] = scope_identity()',N'@0 nvarchar(20),@1 nvarchar(200)',@0=N'Terminated',@1=N'Terminated'
go

/*--------------------------------------------------------------

CREATE SKETCH

--------------------------------------------------------------*/

exec sp_executesql N'insert [dbo].[WorkflowCode]([Code], [Description])
values (@0, @1)
select [WorkflowCodeId]
from [dbo].[WorkflowCode]
where @@ROWCOUNT > 0 and [WorkflowCodeId] = scope_identity()',N'@0 nvarchar(max) ,@1 nvarchar(max) ',@0=N'SketchWf',@1=N'Sketch Workflow'

declare @wc int
select @wc = (
	select WorkflowCodeId
	from WorkflowCode
	where Code = 'SketchWf'
)

exec sp_executesql N'insert [dbo].[WorkflowConfiguration]([ServiceDefinition], [ServiceUrl], [BindingConfiguration], [ServiceEndpoint], [EffectiveDate], [ExpiryDate], [WorkflowCodeId])
values (null, @0, @1, @2, @3, null, @4)
select [WorkflowConfigurationId]
from [dbo].[WorkflowConfiguration]
where @@ROWCOUNT > 0 and [WorkflowConfigurationId] = scope_identity()',N'@0 nvarchar(max) ,@1 nvarchar(max) ,@2 nvarchar(max) ,@3 datetime2(7),@4 int',@0=N'http://localhost/Flow.Tasks.Workflows/SketchWf.xamlx',@1=N'BasicHttpBinding_FlowTasks',@2=N'',@3='2013-01-01 08:30:00.0000000',@4=@wc
go

exec sp_executesql N'insert [dbo].[Property]([Name], [Value], [Type])
values (@0, @1, @2)
select [PropertyId]
from [dbo].[Property]
where @@ROWCOUNT > 0 and [PropertyId] = scope_identity()',N'@0 nvarchar(max) ,@1 nvarchar(max) ,@2 nvarchar(max)',@0=N'SketchWorkflowUrl',@1=N'http://localhost/Flow.Tasks.Workflows/' ,@2=N'S'

exec sp_executesql N'insert [dbo].[Property]([Name], [Value], [Type])
values (@0, @1, @2)
select [PropertyId]
from [dbo].[Property]
where @@ROWCOUNT > 0 and [PropertyId] = scope_identity()',N'@0 nvarchar(max) ,@1 nvarchar(max) ,@2 nvarchar(max)',@0=N'SketchWorkflowPath',@1=N'C:\Dev\Codeplex\FlowTasks\src\Workflows\ServiceWorkflows\' ,@2=N'S'
go

declare @wc int
select @wc = (
	select WorkflowCodeId
	from WorkflowCode
	where Code = 'SketchWf'
)

declare @wfurlp int
select @wfurlp = (
	select PropertyId
	from Property
	where Name = 'SketchWorkflowUrl'
)

declare @wfpathp int
select @wfpathp = (
	select PropertyId
	from Property
	where Name = 'SketchWorkflowPath'
)

exec sp_executesql N'insert [dbo].[WorkflowProperty]([Domain], [WorkflowCodeId], [PropertyId])
values (null, @0, @1)
select [WorkflowPropertyId]
from [dbo].[WorkflowProperty]
where @@ROWCOUNT > 0 and [WorkflowPropertyId] = scope_identity()',N'@0 int ,@1 int',@0=@wc ,@1=@wfurlp

exec sp_executesql N'insert [dbo].[WorkflowProperty]([Domain], [WorkflowCodeId], [PropertyId])
values (null, @0, @1)
select [WorkflowPropertyId]
from [dbo].[WorkflowProperty]
where @@ROWCOUNT > 0 and [WorkflowPropertyId] = scope_identity()',N'@0 int ,@1 int',@0=@wc ,@1=@wfpathp


/*--------------------------------------------------------------

CREATE HOLIDAY

--------------------------------------------------------------*/

exec sp_executesql N'insert [dbo].[WorkflowCode]([Code], [Description])
values (@0, @1)
select [WorkflowCodeId]
from [dbo].[WorkflowCode]
where @@ROWCOUNT > 0 and [WorkflowCodeId] = scope_identity()',N'@0 nvarchar(max) ,@1 nvarchar(max) ',@0=N'HolidayWf',@1=N'Holiday Workflow'

declare @wch int
select @wch = (
	select WorkflowCodeId
	from WorkflowCode
	where Code = 'HolidayWf'
)

exec sp_executesql N'insert [dbo].[WorkflowConfiguration]([ServiceDefinition], [ServiceUrl], [BindingConfiguration], [ServiceEndpoint], [EffectiveDate], [ExpiryDate], [WorkflowCodeId])
values (null, @0, @1, @2, @3, null, @4)
select [WorkflowConfigurationId]
from [dbo].[WorkflowConfiguration]
where @@ROWCOUNT > 0 and [WorkflowConfigurationId] = scope_identity()',N'@0 nvarchar(max) ,@1 nvarchar(max) ,@2 nvarchar(max) ,@3 datetime2(7),@4 int',@0=N'http://localhost/Flow.Tasks.Workflows/HolidayWf.xamlx',@1=N'BasicHttpBinding_FlowTasks',@2=N'',@3='2013-01-01 08:30:00.0000000',@4=@wch
go

/*--------------------------------------------------------------

CREATE REPORTS

--------------------------------------------------------------*/

/****** Object:  StoredProcedure [dbo].[ReportTaskTime]    Script Date: 03/04/2013 08:40:29 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ReportTaskTime]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[ReportTaskTime]
GO

/****** Object:  StoredProcedure [dbo].[ReportTaskTime]    Script Date: 03/04/2013 08:40:29 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

create proc [dbo].[ReportTaskTime](
	@start as datetime,
	@end as datetime
	)
as
begin

select avg(datediff(SECOND, tcrt.[When], tcmp.[When])) as Duration, -- mi = minutes
	tcmp.Code as Task,
	wf.Code as Workflow
from 
	(
		select * from dbo.WorkflowTrace
		where Action in ('TaskCreated')
	) tcrt
	inner join 
		(
			select * from dbo.WorkflowTrace
			where Action in ('TaskCompleted') and
				Result not in ('Expired', 'Terminated')
		) tcmp
	on tcrt.Code = tcmp.Code and tcrt.WorkflowDefinitionId = tcmp.WorkflowDefinitionId
	inner join
	 (
		select wd.WorkflowDefinitionId, wc.Code from dbo.WorkflowDefinition wd
		inner join WorkflowCode wc
		on wd.WorkflowCodeId = wc.WorkflowCodeId		
	) wf 
	on tcmp.WorkflowDefinitionId = wf.WorkflowDefinitionId
where
	(@start is null or @start <= tcmp.[When]) and
	(@end is null or @end >= tcmp.[When])
group by tcmp.Code, wf.Code
order by tcmp.Code, wf.Code

end

GO

/****** Object:  StoredProcedure [dbo].[ReportUserTaskCount]    Script Date: 03/04/2013 08:37:53 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ReportUserTaskCount]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[ReportUserTaskCount]
GO

/****** Object:  StoredProcedure [dbo].[ReportUserTaskCount]    Script Date: 03/04/2013 08:37:53 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

create proc [dbo].[ReportUserTaskCount](
	@start as datetime,
	@end as datetime
	)
as
begin

select lower([User]) as [User], Code as Task, COUNT(*) as [Count] from WorkflowTrace
where Action = 'TaskCompleted' and
	Result not in ('Expired', 'Terminated') and
	(@start is null or @start <= WorkflowTrace.[When]) and
	(@end is null or @end >= WorkflowTrace.[When])	
group by lower([User]), Code

end

GO


/****** Object:  StoredProcedure [dbo].[ReportUserTasks]    Script Date: 03/04/2013 08:37:53 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ReportUserTasks]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[ReportUserTasks]
GO

/****** Object:  StoredProcedure [dbo].[ReportUserTasks]    Script Date: 03/04/2013 08:37:53 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

create proc [dbo].[ReportUserTasks](
	@start as datetime,
	@end as datetime
	)
as
begin

select lower([User]) as [User], COUNT(*) as TaskNo from WorkflowTrace
where Action = 'TaskCompleted' and
	Result not in ('Expired', 'Terminated') and
	(@start is null or @start <= WorkflowTrace.[When]) and
	(@end is null or @end >= WorkflowTrace.[When])
group by lower([User])

end

GO


/****** Object:  StoredProcedure [dbo].[ReportWorkflowTime]    Script Date: 03/04/2013 08:39:10 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ReportWorkflowTime]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[ReportWorkflowTime]
GO

/****** Object:  StoredProcedure [dbo].[ReportWorkflowTime]    Script Date: 03/04/2013 08:39:10 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

create proc [dbo].[ReportWorkflowTime](
	@start as datetime,
	@end as datetime
	)
as
begin

select avg(datediff(SECOND, tcrt.[When], tcmp.[When])) as Duration, -- mi = minutes
	tcmp.Code as Workflow
from 
	(
		select * from dbo.WorkflowTrace
		where Action in ('WorkflowCreated')
	) tcrt
	inner join 
		(
			select * from dbo.WorkflowTrace
			where Action in ('WorkflowCompleted') and
				Result not in ('Expired', 'Terminated')
		) tcmp
	on tcrt.Code = tcmp.Code and tcrt.WorkflowDefinitionId = tcmp.WorkflowDefinitionId
where
	(@start is null or @start <= tcmp.[When]) and
	(@end is null or @end >= tcmp.[When])	
group by tcmp.Code
order by tcmp.Code

end

GO


/*--------------------------------------------------------------

CREATE FULLTEXT TOPIC INDEX

--------------------------------------------------------------*/
CREATE FULLTEXT CATALOG [Topic] WITH ACCENT_SENSITIVITY = ON AS DEFAULT
GO

CREATE FULLTEXT INDEX ON TopicMessage(Message)
KEY INDEX [pk_dbo.TopicMessage] 
	ON Topic
GO

create function SearchTopicForUser
(
	@username nvarchar(16),
    @keywords nvarchar(4000)
)
returns table
as
  return (
	select m.[TopicId], m.[Message], KEY_TBL.[Rank]
	from TopicMessage m
		inner join containstable(TopicMessage, ([Message]),@keywords) AS KEY_TBL
			on m.TopicMessageId = KEY_TBL.[KEY]
		inner join TopicUser u 
			on m.TopicMessageId = u.TopicMessageId
	where u.[User] = @username
		  )

GO

